package P150;

/**
 * @author LiangMu
 * @version \$Id: P39.java, v 0.1, 2024年07月06日 01:57 LiangMu Exp $$
 */
public class P39 {

    public boolean isAnagram(String s, String t) {
        if (s.length() != t.length()) {
            return false;
        }
        int[] ints = new int[26];
        char[] chars1 = s.toCharArray();
        char[] chars2 = t.toCharArray();
        for (int i = 0; i < chars1.length; i++) {
            int index1 = chars1[i] - 'a';
            int index2 = chars2[i] - 'a';
            ints[index1]++;
            ints[index2]--;
        }
        for (int it : ints) {
            if (it != 0) {
                return false;
            }
        }
        return true;
    }

}
